<html>
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/googleapis/0.0.2/googleapis.min.js"></script>
  <script>
  function printResponse(msg) {
    if (typeof(msg) === 'object') {
      // TODO: Fix this for browsers without JSON
      msg = JSON.stringify(msg);
    }
    document.getElementById('response').value = msg;
  }

  function makeRequest() {
    googleapis.newRequest('chili.activities.search', {'q': 'homer'}).execute(
      function(resp) {
        var error = null;
        if ('error' in resp) {
          error = resp['error'];
        }
        if (error) {
          printResponse('ERROR ' + error.code + ': ' + error.message);
          return;
        }
        printResponse(resp);
      }
    );
  }
  </script>
</head>
<body>
<a href="javascript:void(0);" onclick="makeRequest()">Search Buzz for 'homer'</a><br /><br />
<div>
<b>Response</b><br />
<textarea id="response" style="width: 500px; height: 500px;"></textarea>
</div>
</body>
</html>
